/**
 * Created by zhuwei on 2017/7/25.
 */
function doLogin(url,isNewTab,forceLogin){
    url = url || '/login';
    var loginUserName = '';
    if(loginUserName != null && loginUserName != undefined && loginUserName !=''){
        if(url!= null && url!= undefined && url!=''){
            if(url.indexOf("inquiryAdd")>0
                || url.indexOf("abilityPublish")>0
                || url.indexOf("createEnquiry")>0
                || url.indexOf("createCapability")>0){
                if(isPersonal()){
                    alert("个人用户不能发布信息！");
                    return false;
                }
            }
            url = initUrl(url);
        }
    }

    if(forceLogin){
        url = '/login?spring-security-redirect=' + url;
    }

    //设置从哪登录，登录之后回哪
    if(!isNewTab){
        url = '/login?spring-security-redirect=' + encodeURIComponent(window.location.href);
    }

    openTab(url,isNewTab);
}

function openTab(url,isNewTab){
    if(isNewTab){
        window.open(url);
    }else{
        window.location = url;
    }
}

function userCheck(userName, springName, userId, moreinfo) {
    if(!userName) {
        return;
    }
    if(userId) {
        if(userId.userid)
            window.HT_UID = userId.userid;
        if(userId.orgid)
            window.HT_OID = userId.orgid;
    }
    window.springName = springName;
    if(moreinfo && moreinfo.jituan)
        window.jituan = true;
    else
        window.jituan = false;
    if(window.NTKF_PARAM) {
        window.NTKF_PARAM.uid = window.NTKF_PARAM.uname = window.springName;
    }

    var fullname = $('<s>' + userName + '</s>').text();
    if(fullname) {
        $('.unlogin_panel').hide(); $('.login_panel').show();
        $('#currentName').text(fullname).attr('title', fullname);
    }
}

function fullSearch(obj,inputId){
    var searchVal = $(inputId).val();
    if(searchVal=="请输入关键词"){
        $(".form-search-bar").val('');
    }
    $(obj).closest("form").submit();
}